import AppLayout from "@/Layout/index.vue";
import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const originalPush = VueRouter.prototype.push;

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const routes = [
  {
    path: "/",
    redirect: "/home"
  },
  {
    path: "/home",
    component: AppLayout,
    children: [
      {
        path: "",
        name: "home",
        component: () => import("@/views/Home/index.vue")
      }
    ]
  },
  {
    path: "/autoRepayment", // 自动还款
    component: AppLayout,
    children: [
      {
        path: "",
        name: "finance",
        component: () => import("@/views/autoRepayment/index.vue")
      }
    ]
  },
  {
    path: "/applyCard", // 立即办卡
    component: AppLayout,
    children: [
      {
        path: "",
        name: "applyCard",
        meta: {
          // needAuth: true
        },
        component: () => import("@/views/applyCard/index.vue")
      },
      {
        path: "/cardDetail",
        name: "cardDetail",
        meta: {
          // needAuth: true
        },
        component: () =>
          import("@/views/applyCard/components/cardDetail/index.vue")
      },
      {
        path: "/applyCardResult",
        name: "applyCardResult",
        meta: {
          // needAuth: true
        },
        component: () => import("@/views/applyCard/components/result/index.vue")
      }
    ]
  },
  {
    path: "/activateCard", // 卡片激活
    component: AppLayout,
    children: [
      {
        path: "",
        name: "activateCard",
        meta: {
          // needAuth: true
        },
        component: () => import("@/views/activateCard/index.vue")
      }
    ]
  },
  {
    path: "/BillingDetail", // 账单明细
    component: AppLayout,
    children: [
      {
        path: "",
        name: "BillingDetail",
        meta: {
          // needAuth: true
        },
        component: () => import("@/views/BillingDetail/index.vue")
      },
      {
        path: "/billInfo",
        name: "billInfo",
        meta: {
          // needAuth: true
        },
        component: () => import("@/views/BillingDetail/billInfo.vue")
      }
    ]
  },
  ,
  {
    path: "/repaymentDetail", // 还款明细
    component: AppLayout,
    children: [
      {
        path: "",
        name: "repaymentDetail",
        meta: {
          // needAuth: true
        },
        component: () => import("@/views/repaymentDetail/index.vue")
      },
      {
        path: "/tradeDetail",
        name: "tradeDetail",
        meta: {
          // needAuth: true
        },
        component: () => import("@/views/repaymentDetail/tradeDetail.vue")
      }
    ]
  },
  {
    path: "/repayment", // 查账 还款
    component: AppLayout,
    children: [
      {
        path: "",
        name: "repayment",
        component: () => import("@/views/repayment/index.vue")
      },
      {
        path: "quikcRePayment",
        name: "quikcRePayment",
        component: () =>
          import("@/views/repayment/views/quikcRePayment/index.vue")
      },
      {
        path: "rePaymentResult",
        name: "rePaymentResult",
        component: () =>
          import("@/views/repayment/views/rePaymentResult/index.vue")
      }
    ]
  },
  {
    path: "/splitPeriod", // 我要分期
    component: AppLayout,
    children: [
      {
        path: '',
        name: 'splitPeriod',
        component: () => import('@/views/splitPeriod/index.vue')
      },
      {
        path: 'splitPeriodConfirm',
        name: 'splitPeriodConfirm',
        component: () => import('@/views/splitPeriod/views/splitPeriodConfirm/index.vue')
      }
    ]
  },
  {
    path: '/HuNanRegionPoc',
    name: 'HuNanRegionPoc',
    component: AppLayout,
    children: [
      {
        path: '',
        name: 'HuNanRegionPoc',
        component: () => import('@/views/HuNanPocPage/views/HomePage/index.vue')
      }
    ]
  },
  {
    path: "/Login",
    name: "Login",
    component: () => import("@/views/Login/index.vue")
  }
];

const router = new VueRouter({
  mode: "hash",
  // base: process.env.BASE_URL,
  routes
});

export default router;
